package cn.ljy.mes.model;

import cn.ljy.authority.model.SysUser;
import cn.ljy.common.model.BaseModel;
import cn.ljy.common.model.validate.AddWorkValidation;
import cn.ljy.common.model.validate.UpdateWorkValidation;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * 汽车生产工单实体类
 */
@ApiModel(value = "汽车生产工单")
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = false, of = {"id"})
public class MesProductionOrder extends BaseModel {

    @ApiModelProperty(value = "生产工单ID", example = "01f15383-7cb4-11f0-92a2-0250f2000002")
    @NotNull(groups = UpdateWorkValidation.class, message = "生产工单ID不能为空")
    private String id;

    @ApiModelProperty(value = "商城订单关联对象", required = true)
    @NotNull(groups = AddWorkValidation.class, message = "商城订单不能为空")
    private ShopCarOrder shopCarOrder;

    @ApiModelProperty(value = "商城订单ID",notes = "仅用于数据库检索（虽然有关联字段shopCarOrder，但是关联字段需要连表查询，故针对检索频率高的字段加上这个），不作为查询条件、插入、更新、删除的依据字段")
    private String orderId;

    @ApiModelProperty(value = "关联的汽车配置对象", required = true)
    @NotNull(groups = AddWorkValidation.class, message = "汽车配置不能为空")
    private MesCarModelConfig carModelConfig;//预留字段，不算冗余字段，保留了完整的生产配置信息，避免商城与生产的藕合和以后的调整，也提高检索效率。

    @ApiModelProperty(value = "关联的生产工艺对象，由系统直接判断", required = false)
    private MesCarTechnology carTechnology;
    @ApiModelProperty(value = "生产工艺对象id",notes = "仅用于数据库检索（虽然有关联字段carTechnology，但是关联字段需要连表查询，故针对检索频率高的字段加上这个），不作为查询条件、插入、更新、删除的依据字段")
    private String technologyId;

    @ApiModelProperty(value = "车辆识别号(VIN)", required = true, example = "LGWEF4A51NL123456")
    private String vin;

    @ApiModelProperty(value = "生产状态", required = true,
            allowableValues = "planned,in_progress,paused,completed,cancelled",
            example = "planned")
    private String status;

    @ApiModelProperty(value = "开始生产时间", example = "2025-08-18 12:28:26")
    private Date startTime;

    @ApiModelProperty(value = "完成生产时间", example = "2025-08-19 12:29:32")
    private Date endTime;

    @ApiModelProperty(value = "审核员")
    private SysUser auditor;

    @ApiModelProperty(value = "整车检查通过状态", example = "true")
    private Boolean auditResult;
    @ApiModelProperty(value = "整车检通过或者不通过的理由", example = "质量有问题")
    private String auditNote;

    @ApiModelProperty(value = "创建时间", example = "2025-08-19 12:29:32")
    private Date createTime;

    @ApiModelProperty(value = "更新时间", example = "2025-08-19 12:30:00")
    private Date updateTime;

    public MesProductionOrder(String id) {
        this.id = id;
    }

    //非数据库字段
    @ApiModelProperty(value = "当前生产步骤")
    private Integer currentStep = 0;
    @ApiModelProperty(value = "详细生产步骤集合")
    private List<MesProductionOrderStep> steps=new ArrayList<>();//生产步骤明细
}